@charset "utf-8";

:root {
    --max-width: 2048px;
    --min-width: 200px; /* 当列的宽度小于此值时，部分行内容会被从横向改变纵向排列。 */
    --padding: 1rem;
    --article-padding: calc(var(--padding) / 2);

    --color: black;
    --accent-color: #0074d9;
    --background: white;
    --border-color: #e0e0e0;
    --delete-color: red;

    /* method */
    --method-get-color: green;
    --method-options-color: green;
    --method-post-color: darkorange;
    --method-put-color: darkorange;
    --method-patch-color: darkorange;
    --method-delete-color: red;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color: #b0b0b0;
        --accent-color: #0074d9;
        --background: black;
        --border-color: #303030;
        --delete-color: red;

        /* method */
        --method-get-color: green;
        --method-options-color: green;
        --method-post-color: darkorange;
        --method-put-color: darkorange;
        --method-patch-color: darkorange;
        --method-delete-color: red;
    }
}

body {
    padding: 0;
    margin: 0;
    color: var(--color);
    background: var(--background);
    text-align: center;
}

table {
    width: 100%;
}

table tr {
    cursor: pointer;
}

table th, table td {
    font-weight: normal;
    text-align: left;
    border-bottom: 1px solid transparent;
}

table tr:hover th,
table tr:hover td {
    opacity: .7;
}

ul, ol, ul li, ol li {
    padding: 0;
    margin: 0;
    list-style-position: inside;
}

p {
    margin: 0;
}

summary, input {
    outline: none;
}

a {
    text-decoration: none;
    color: var(--accent-color);
}

a:hover {
    opacity: .7;
}

.del {
    text-decoration: line-through;
    text-decoration-color: var(--delete-color);
}

.hidden {
    display: none;
}

/*************************** header ***********************/

header {
    position: sticky;
    top: 0;
    display: block;
    z-index: 1000;
    box-sizing: border-box;
    background: var(--background);
    box-shadow: 2px 2px 2px var(--border-color);
}

header .wrap {
    margin: 0 auto;
    text-align: left;
    max-width: var(--max-width);
    padding: 0 var(--padding);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: var(--padding) 0 var(--article-padding);
    display: inline-block;
}

header h1 .version {
    font-size: 1rem;
}

header h1 img {
    height: 1.5rem;
    margin-right: .5rem;
}


header .menus {
    display: flex;
}

header .menu {
    cursor: pointer;
    position: relative;
    margin-left: var(--padding);
    display: none; /* 默认不可见，只有在有 JS 的情况下，通过 JS 控制其可见性 */
}

header .menu:hover span {
    opacity: .7;
}

header .menu ul {
    position: absolute;
    min-width: 4rem;
    right: 0;
    display: none;
    list-style: none;
    background: var(--background);
    border: 1px solid var(--border-color);
    padding: var(--article-padding);
}

header .menu ul li {
    padding-bottom: var(--article-padding);
}

/* 可以保证 label 的内容在同一行 */
header .menu ul li label {
    display: inline-flex;
    align-items: baseline;
    word-break: keep-all;
    white-space: nowrap;
    cursor: pointer;
}

header .menu ul li:hover label {
    opacity: .7;
}

header .menu ul li:last-of-type {
    padding-bottom: 0;
}

header .menu:hover ul {
    display: block;
}

/*************************** main ***********************/

main {
    padding: 0 var(--padding);
    margin: 0 auto;
    max-width: var(--max-width);
    text-align: left;
}

main .content {
    margin: var(--padding) 0;
}

/****************** .servers *******************/

main .servers {
    display: flex;
    flex-flow: wrap;
    justify-content: space-between;
    margin-bottom: var(--padding);
}

main .servers .server {
    flex-grow: 1;
    min-width: var(--min-width);
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    padding: var(--padding) var(--article-padding);
}

main .servers .server:hover {
    border: 1px solid var(--accent-color);
}

main .servers .server h4 {
    margin: 0 0 var(--padding);
}

/********************** .api **********************/

main .api {
    margin-bottom: var(--article-padding);
    border: 1px solid var(--border-color);
}

main .api>summary {
    margin: 0;
    padding: var(--article-padding);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    line-height: 1;
    box-sizing: border-box;
}


main details.api:not([open])>summary {
    border: none;
}


main .api>summary .action {
    width: 40%;
    display: inline-block;
}

main .api>summary .right {
    width: calc(60% - 2rem); /* 2rem 表示左侧的箭头 */
    float: right;
}

main .api>summary .right .srv,
main .api>summary .right .summary {
    width: 50%;
    display: inline-block;
}

/* 200px 为 --min-width 的值 */
@media (max-width: calc(200px * 2)) {
    main .api>summary .action {
        width: 50%;
    }

    main .api>summary .right {
        width: calc(50% - 2rem);
    }

    main .api>summary .right .srv {
        display: none;
    }

    main .api>summary .right .summary {
        width: 100%;
    }
}

main .api>summary .link {
    margin-right: 10px;
    text-decoration: none;
}

main .api>summary .method {
    min-width: 4rem;
    font-weight: bold;
    display: inline-block;
    margin-right: 1rem;
}

main .api .callback .summary,
main .api>summary .summary {
    font-weight: 400;
    opacity: .8;
    text-align: right;
}

main .api .description {
    padding: var(--article-padding);
    margin: 0;
    border-bottom: 1px solid var(--border-color);
}

main .api[data-method='GET'][open],
main .api[data-method='GET']:hover,
main .callback[data-method='GET'] h3 {
    border: 1px solid var(--method-get-color);
}
main .api[data-method='GET']>summary {
    border-bottom: 1px solid var(--method-get-color);
}

main .api[data-method='POST'][open],
main .api[data-method='POST']:hover,
main .callback[data-method='POST'] h3 {
    border: 1px solid var(--method-post-color);
}
main .api[data-method='POST']>summary {
    border-bottom: 1px solid var(--method-post-color);
}

main .api[data-method='PUT'][open],
main .api[data-method='PUT']:hover,
main .callback[data-method='PUT'] h3 {
    border: 1px solid var(--method-put-color);
}
main .api[data-method='PUT']>summary {
    border-bottom: 1px solid var(--method-put-color);
}

main .api[data-method='PATCH'][open],
main .api[data-method='PATCH']:hover,
main .callback[data-method='PATCH'] h3 {
    border: 1px solid var(--method-patch-color);
}
main .api[data-method='PATCH']>summary {
    border-bottom: 1px solid var(--method-patch-color);
}

main .api[data-method='DELETE'][open],
main .api[data-method='DELETE']:hover,
main .callback[data-method='DELETE'] h3 {
    border: 1px solid var(--method-delete-color);
}
main .api[data-method='DELETE']>summary {
    border-bottom: 1px solid var(--method-delete-color);
}

main .api[data-method='OPTIONS'][open],
main .api[data-method='OPTIONS']:hover,
main .callback[data-method='OPTIONS'] h3 {
    border: 1px solid var(--method-options-color);
}
main .api[data-method='OPTIONS']>summary {
    border-bottom: 1px solid var(--method-options-color);
}

main .callback h3 {
    display: flex;
    justify-content: space-between;
    padding: var(--article-padding) var(--padding);
    margin: 0;
    border-left: none !important;
    border-right: none !important;
    cursor: pointer;
    line-height: 1;
}

main .api .body {
    display: flex;
    flex-flow: wrap;
}

main .api .title,
main .api .title {
    margin: var(--article-padding) 0 0;
    font-weight: normal;
}

main .api .body .responses .status {
    margin: var(--padding) 0 var(--article-padding);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 3px;
}

main .api .param .parent-type {
    opacity: .5;
}

main .api .body .requests,
main .api .body .responses {
    flex: 1 1 50%;
    box-sizing: border-box;
    min-width: var(--min-width);
}
main .api .body .requests {
    border-right: 1px dotted var(--border-color);
}

main .api .body .requests .header,
main .api .body .responses .header {
    margin: 0;
    opacity: .5;
    padding: var(--article-padding);
}

main .api .body .requests details:not([open]),
main .api .body .responses details:not([open]) {
    margin-bottom: var(--article-padding);
}

main .api .body .requests>.param,
main .api .body .requests details summary ~ *,
main .api .body .responses details summary ~ * {
    padding: 0 var(--article-padding);
}

main .api .responses details summary,
main .api .requests details summary {
    cursor: pointer;
    padding: var(--article-padding);
}

main .api .responses details[open] summary,
main .api .requests details[open] summary,
main .api .responses details summary:hover,
main .api .requests details summary:hover {
    cursor: pointer;
    background-color: var(--border-color);
    padding: var(--article-padding);
}

/*************************** footer ***********************/

footer {
    border-top: 1px solid var(--border-color);
    padding: var(--padding) var(--padding);
    text-align: left;
    margin-top: var(--padding);
}

footer .wrap {
    margin: 0 auto;
    max-width: var(--max-width);
}

.goto-top {
    border: solid var(--color);
    border-width: 0 5px 5px 0;
    display: block;
    padding: 5px;
    transform: rotate(-135deg);
    position: fixed;
    bottom: 3rem;
    right: calc(((100% - var(--max-width)) / 2) - 3rem);
}

/*
 * 用于计算 goto-top 按钮的位置始终保持在内容主体的右侧边上。
 * 2048px 为 --max-width 的值，但是 CSS 并不支持直接在 @media
 * 使用 var() 函数。
 */
@media (max-width: calc(2048px + 6rem)) {
    .goto-top {
        right: 3rem;
    }
}
